// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0


import { ListView } from "std-widgets.slint";

export component  TestCase {
    height: 150px;
    width: 150px;
    in-out property <int> clicked;
    in-out property viewport-y <=> lv.viewport-y;
    in-out property <[int]> mod: [0,1,2,3,4,5,6,7,8,9];



    lv := ListView {
        for i in mod: Rectangle {
            height: 20px;
            property <int> internal_state: 1;
            TouchArea {
                clicked => {
                    root.clicked += internal_state * i;
                    internal_state += 10000;
                }
            }
        }
    }

    Text { text: clicked; }

}

/*


```rust
let instance = TestCase::new().unwrap();

slint_testing::send_mouse_click(&instance, 50., 5.);
assert_eq!(instance.get_clicked(), 0);

slint_testing::send_mouse_click(&instance, 50., 25.);
assert_eq!(instance.get_clicked(), 1);
instance.set_clicked(0);

slint_testing::send_mouse_click(&instance, 50., 85.);
assert_eq!(instance.get_clicked(), 4);

instance.set_clicked(0);

let another_model = std::rc::Rc::new(slint::VecModel::<i32>::from(
    vec![10,11,12,13,14,15,16,17,18,19]));

instance.set_mod(slint::ModelRc::from(another_model.clone()));

slint_testing::send_mouse_click(&instance, 50., 5.);
assert_eq!(instance.get_clicked(), 10);

instance.set_clicked(0);

slint_testing::send_mouse_click(&instance, 50., 45.);
assert_eq!(instance.get_clicked(), 12);
instance.set_clicked(0);

slint_testing::send_mouse_click(&instance, 50., 85.);
assert_eq!(instance.get_clicked(), 14);

```

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;

slint_testing::send_mouse_click(&instance, 50., 5.);
assert_eq(instance.get_clicked(), 0);

slint_testing::send_mouse_click(&instance, 50., 25.);
assert_eq(instance.get_clicked(), 1);
instance.set_clicked(0);

slint_testing::send_mouse_click(&instance, 50., 85.);
assert_eq(instance.get_clicked(), 4);

instance.set_clicked(0);

auto another_model = std::make_shared<slint::VectorModel<int>>(std::vector{10, 11, 12, 13, 14, 15, 16 });
instance.set_mod(another_model);

slint_testing::send_mouse_click(&instance, 50., 5.);
assert_eq(instance.get_clicked(), 10);

instance.set_clicked(0);

slint_testing::send_mouse_click(&instance, 50., 45.);
assert_eq(instance.get_clicked(), 12);
instance.set_clicked(0);

slint_testing::send_mouse_click(&instance, 50., 85.);
assert_eq(instance.get_clicked(), 14);


```


*/
